home *** CD-ROM | disk | FTP | other *** search
- Path: thor.tu.hac.com!collins
- From: collins@thor.tu.hac.com (Ron Collins)
- Newsgroups: comp.lang.c
- Subject: Re: Does Borland C++ 5.0 still work with normal C???
- Date: 27 Feb 1996 21:47:51 GMT
- Organization: Advanced Depot Systems
- Message-ID: <4gvu67$es7@hacgate2.hac.com>
- References: <n4mwd.33.000A228B@magg.net> <4gdkv3$q8a@druid.borland.com> <4ggsie$1fg@dopey.magg.net> <4gqdf7$jfo@redstone.interpath.net>
- NNTP-Posting-Host: thor.tu.hac.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Scott McMahan - Softbase Systems (softbase@mercury.interpath.net) wrote:
- : Dennis Hawkins (n4mwd@magg.net) wrote:
-
- : : printf("%ld\n", (long) sizeof 'a');
-
- : : and produce an EXE that generates '2' for the output.
-
- : How do you get two out of this? A char is 1, and casting that to a long
- : is still 1, only it takes up more bytes. How can this evaluate to 2?
- : sizeof char being 1 is kinda hard-wired into the language.
-
- The expression in question is "sizeof 'a'", which returns the size of
- an expression, not a type. The result type of the expression 'a' is an
- int, not a char. Therefore, "(sizeof 'a') => 2" is correct.
-
-
- -- collins --
-